from openpyxl import load_workbook


class excel():
    def __init__(self, path, sheetname):
        self.path = load_workbook(path)
        self.sheetname = self.path[sheetname]

    def get_data(self):
        datalist = []
        for line in self.sheetname:
            lis = []
            lis.append(line[0].value)
            lis.append(line[1].value)
            lis.append(line[3].value)
            lis.append(line[7].value)
            lis.append(line[8].value)
            lis.append(line[9].value)
            lis.append(line[10].value)
            lis.append(line[11].value)
            datalist.append(lis)
        datalist.pop(0)
        return datalist

    def write(self):
        lw = load_workbook(r'D:\gao5biji\wenjian\newgw\unit__002\unit_01\data.xlsx')
        ws = lw.active
        ws['A15'] = 'aaa'
        lw.save(r'D:\gao5biji\wenjian\newgw\unit__002\unit_01\data.xlsx')


if __name__ == '__main__':
    path = r'D:\gao5biji\wenjian\newgw\unit__002\unit_01\data.xlsx'
    sheetname = 'Sheet1'
    db = excel(path, sheetname)
    print(db.get_data())

    db.write()
